﻿using System;
using System.Linq;
using System.Collections.Generic;

namespace JingQiao.Ads.Domain.Model
{
    /// <summary>
    /// Really Context is the main class for interact with data and this is
    /// used usually in repositories for storing and query data. For mantein PI
    /// into Domain Layer and add features for Mocking this context is expressed 
    /// as interfaces and fluent this into repositories implementation.
    /// </summary>
    public interface IContext
         : IUnitOfWork
    {
        /// <summary>
        /// Apply changes made in item or related items in your graph
        /// </summary>
        /// <typeparam name="TEntity">Type of item</typeparam>
        /// <param name="item">Item with changes</param>
        void SetChanges<TEntity>(TEntity item)
            where TEntity : class,new(); //IObjectWithChangeTracker, 

        void SetSearchQuery(string query);

        IQueryable<TEntity> GetQueryable<TEntity>();

        void Insert<TEntity>(TEntity entity);

        void InsertAll<TEntity>(IEnumerable<TEntity> instances);

        void Delete<TEntity>(TEntity entity);

        void DeleteAll<TEntity>(IEnumerable<TEntity> instances);
    }
}
